<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <title>新闻展示页</title>
</head>
<body>
<header align="center">
    <h2><a th:href="|@{'/'}news|">新闻内容管理系统</a></h2>
    <br/>
    <p>
        用户名:<span sec:authentication="name"></span>
    <form name="logoutForm" th:action="@{/logout}" method="post">
        <input type="submit" value="退出登录"/>
    </form>
    </p>

</header>

<h1>新闻展示</h1>
<span th:text="|共${newsList.size()}条数据|"></span>
<p>
    <a th:href="@{'news/add'}" sec:authorize="hasRole('ADMIN')"><button>添加新闻</button></a>
</p>
<div>
    <table border="1">
        <tr>
            <th>序号</th>
            <th>标题</th>
            <th>内容</th>
            <th>时间</th>
            <th>操作</th>
        </tr>

        <tr th:each="news,stat:${newsList}">
            <td th:text="${news.id}"></td>
            <td style="max-width:400px;overflow:hidden; text-overflow:ellipsis;white-space:nowrap"
                th:text="${news.title}"></td>
            <td style="max-width:800px;overflow:hidden; text-overflow:ellipsis;white-space:nowrap"
                th:text="${news.content}"></td>
            <td th:text="${#temporals.format(news.createTime,'yyyy-MM-dd HH:mm')}"></td>
            <td>
                <a th:href="@{'/news/' + ${news.id}}">查看</a>
                <a th:href="|@{'/news/edit/'}${news.id}|" sec:authorize="hasRole('ADMIN')">编辑</a>
                <!--<a th:href="@{'/news/delete/'+${news.id}}" sec:authorize="hasRole('ADMIN')">删除</a>-->
            </td>
        </tr>
    </table>
</div>
</body>
</html>
   